﻿using System;
using System.Collections.Generic;
using Infrastructure.Domain;

namespace SocialFront.Core.Domain
{
    // Cart
    public class Cart
    {
        public IList<CartItem> CartItems { get; set; }
    }

    public class CartItem
    {
        public Product Product { get; set; }
        public int Quantity { get; set; }
        public Cart Cart { get; set; }
    }

    // Product
    public abstract class ProductAttribute : EntityBase
    {
        public string Name { get; set; }
    }

    public class ProductColor : ProductAttribute
    {
    }

    public class ProductSize : ProductAttribute
    {
    }

    public class Category : ProductAttribute
    {
        public int ? ParentCategoryId { get; set; }
        public Category ParentCategory { get; set; }
    }

    public class Product : EntityBase
    {
        public string Name { get; set; }
        public virtual Decimal Price { get; set; }
        public virtual ProductColor Color { get; set; }
        public virtual ProductSize Size { get; set; }
        public virtual Category Category { get; set; }
    }

    // Complex class.
    public class Address : EntityBase
    {
        public string AddressLine1 { get; set; }
        public string AddressLine2 { get; set; }
        public string City { get; set; }
        public string State { get; set; }
        public string Country { get; set; }
        public string ZipCode { get; set; }
    }

    public class DeliveryAddress : Address
    {
        public virtual Customer Customer { get; set; }
        public string Nickname { get; set; }
    }

    public class Email : EntityBase
    {
        public string EmailAddress { get; set; }
        public bool IsPrimary { get; set; }
    }

    public class Customer : EntityBase
    {
        public string FirstName { get; set; }
        public string MiddleName { get; set; }
        public string LastName { get; set; }

        public virtual IList<Email> EmailBook { get; set; }
        public virtual IList<DeliveryAddress> DeliveryAddressBook { get; set; }
    }

    // Orders and payments ...
    public class Merchant : EntityBase
    {
        public string Name { get; set; }
    }

    public class OrderItem : EntityBase
    {
        public int Quantity { get; set; }

        public int OrderId { get; set; }
        public Order Order { get; set; }

        public int ProductId { get; set; }
        public virtual Product Product { get; set; }
    }

    public enum OrderStatus
    {
        Open      = 1,
        Submitted = 2
    }

    public class Order : EntityBase
    {
        public DateTime Created { get; set; }
        public DateTime DatePaid { get; set; }
        public string TransactionId { get; set;}
        public decimal Amount { get; set; }
        public int OrderStatus { get; set; }

        // Navigation  
        public int MerchantId { get; set; }
        public virtual Merchant Merchant { get; set; }

        public int  DeliveryAddressId { get; set; }
        public virtual Address DeliveryAddress { get; set; }

        public int CustomerId { get; set;}
        public virtual Customer Customer { get; set; }

        public int ShippingServiceId { get; set; }
        public virtual ShippingService ShippingService { get; set; }
        public virtual IList<OrderItem> OrderItems { get; set; }
    }
    
    // Shipping
    public class ShippingService : EntityBase
    {
        public string Code { get; set; }
        public string Description { get; set; }
        public virtual Courier Courier { get; set; }
    }

    public class Courier : EntityBase
    {
        public string Name { get; set; }
        public virtual IList<ShippingService> ShippingServices { get; set; }
    }
}